# #!/user/bin/env python3
# # -*- coding: utf-8 -*-
# import os
# from plistlib import dumps, dump
#
# import pymysql
# from sshtunnel import SSHTunnelForwarder
#
# from Common.getpath import *
# from Common.yaml_util import YamlUtil
#
# print(os.path.join((os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
#
#
#
# # import requests
# #
# # pam = {'keyword': '', 'pageNum': 2}
# #
# # re = requests.get(url="https://gesdt.shb.ltd/task/getTagListForAll?keyword=&pageNum=2",
# #                   headers={'Host': '<calculated when request is sent>', 'User-Agent': 'PostmanRuntime/7.28.3',
# #                            'Accept': '/', 'Accept-Encoding': 'gzip, deflate, br', 'Connection': 'keep-alive',
# #                            'cookies': 'VIPPUBLINKJSESSIONID=ce92f61a-20c9-4094-a354-05989571dc2c'}
# #                   )
# #
# # print(re.status_code)
#
#
# server =  SSHTunnelForwarder(
#         ("47.97.91.2", 22),
#         ssh_username= "root",
#         ssh_pkey="Docker@publink",
#         remote_bind_address=('ge-east-prd.mysql.database.chinacloudapi.cn', 13306),
#         # local_bind_address=('0.0.0.0', 3306)
# )
# server.start()
#
# client = pymysql.connect(host='127.0.0.1',  # 此处必须是是127.0.0.1
#                               port=13306,
#                               user='read@ge-east-prd',
#                               passwd='i2BiKXQ#mZoPOja3',
#                               db='')



    # conn = pymysql.connect(
    #     host='127.0.0.1',  # 此处必须是是127.0.0.1
    #     port=3306,
    #     user="read@ge-east-prd",
    #     passwd="i2BiKXQ#mZoPOja3"
    # )
    # cur = conn.cursor()
    # cur.execute("show databases")
    # print(cur.fetchall())
# import mysql.connector
# import sshtunnel
#
# with sshtunnel.SSHTunnelForwarder(
#         ("47.97.91.2", 22),
#         ssh_username="root",
#         ssh_password="Docker@publink",
#         remote_bind_address=('ge-east-prd.mysql.database.chinacloudapi.cn', 3306),
#         local_bind_address=('127.0.0.1', 13306)
# ) as tunnel:
#     conn = mysql.connector.connect(
#         user='read@ge-east-prd',
#         password='i2BiKXQ#mZoPOja3',
#         host='127.0.0.1',
#         port=13306,
#         database='tr2676callcenter'
#     )
#     cursor = conn.cursor()
#     query = "select version();"
#     cursor.execute(query)
#     data = cursor.fetchall()
#     print(data)
# import pymysql
# from sshtunnel import SSHTunnelForwarder
#
#
# # 传入实例名和sql，返回查询结果
# def SSHMysql(DB, SQL):
#     # 配置SSH连接
#     server = SSHTunnelForwarder(
#         ssh_address_or_host= ("47.97.91.2", 22),
#         ssh_username="root",
#         ssh_password="Docker@publink",
#         remote_bind_address=('ge-east-prd.mysql.database.chinacloudapi.cn', 3306),
#         local_bind_address=('127.0.0.1', 13306))
#     server.start()  # 启用SSH
#     # 数据库账户信息设置
#     db = pymysql.connect(
#         user='read@ge-east-prd',
#         password='i2BiKXQ#mZoPOja3',
#         host='127.0.0.1',
#         port=13306,
#         database='tr2676callcenter',
#         charset='utf8')
#
#     cursor = db.cursor()
#     cursor.execute(SQL.encode('utf8'))  # 执行SQL
#     data = cursor.fetchall()  # 获取查询结果
#
#     # 关闭数据库连接
#     cursor.close()
#     return data
#
#
# if __name__ == "__main__":
#     SQL = "SELECT * from base_app_version;"
#     SelectResult = SSHMysql('db_cust', SQL)
#     print(SelectResult)

from Common.database import *
from Common.getpath import *
sql = "SELECT * from base_app_version;"
print(getmysql().run_sql(sql=sql))